using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.BLL;
using emp.Utility;

public partial class crm_nurturing_Nurturing_Individuals : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            if (Request["ndd_id"] != null && Request["ndd_id"] != "")
            {
                this.ndd_id.Value = Request["ndd_id"];
            }
            if (Request["state"] != null && Request["state"] != "")
            {
                this.state.Value = Request["state"];
            }
            if (Request["cur_page"] != null && Request["cur_page"] != "")
            {
                this.curpage.Value = Request["cur_page"];
            }
            if (Request["ed_uid"] != null && Request["ed_uid"] != "")
            {
                this.ed_uid.Value = Request["ed_uid"];
            }
            init();
        }
    }
    protected void back_Click(object sender, EventArgs e)
    {
        if (this.state.Value.Equals("0"))
        {
            Response.Redirect("NurturingListsInfo.aspx?eduid=" + this.ed_uid.Value + "&cur_page=" + this.curpage.Value + "&state=" + this.state.Value);
        }
        if (this.state.Value.Equals("1"))
        {
            Response.Redirect("NurturingInfo.aspx?eduid=" + this.ed_uid.Value + "&cur_page=" + this.curpage.Value + "&state=" + this.state.Value);
        }
       
       
    }
    
    protected void datalist_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        GridView theGrid = sender as GridView;
        int newPageIndex = 0;

        if (-2 == e.NewPageIndex)
        {
            TextBox txtNewPageIndex = null;
            GridViewRow pagerRow = theGrid.BottomPagerRow;
            if (null != pagerRow)
            {
                txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
            }
            if (null != txtNewPageIndex)
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }

        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        theGrid.PageIndex = newPageIndex;
        init();
    }
    private void init()
    {
        Nurturing nur = new Nurturing();
        string[] parm = new string[1];
        parm[0] = this.ndd_id.Value;
        IList data = nur.getNurturingIndividuals(parm);
        datalist.DataSource = data;
        datalist.DataBind();
        PageUtil.setPageCount(datalist, data.Count);

      
    }
    
}
